﻿using Engine;
using Game.NetWork.Packages;
using Game.NetWork;
using Game.Server.Event;
using Game.Server.PlayerEvent;
using System;
using Game.IContentReader;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using Newtonsoft.Json;
using static Game.SubsystemCreatureSpawn;
using GameEntitySystem;

namespace Game.Server.Plugins
{
    public class AnimalRandomSpawnZHPlugin : ServerPlugin, ICreatureSpawnEventHandle
    {
        public class Condition
        {
            public List<string> Creatures;
            public List<int> BlockValues;
            public Vector2 Temperature;
            public Vector2 Humidity;
            public Vector2 Light;
            public Vector2 High;
            public float Probability;
        }

        public override int Version => 10000;

        public override string Name => "动物生成条件修改";

        public byte FirstLevel => 0;

        public SubsystemCreatureSpawn m_subsystemCreatureSpawn;

        public SubsystemTerrain m_subsystemTerrain;

        public override void Initialize()
        {
            CreatureSpawnEventManager.AddObject(this);
        }

        public bool Update(SubsystemCreatureSpawn subsystemCreatureSpawn, float dt)
        {
            return true;
        }

        public List<Entity> SpawnCreatures(CreatureType creatureType, string templateName, Point3 point, int count)
        {
            return m_subsystemCreatureSpawn.SpawnCreatures(creatureType, templateName, point, count);
        }

        public float LightCondition(Point3 point)
        {
            //int light = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
            int id = m_subsystemTerrain.Terrain.GetCellContents(point.X, point.Y - 1, point.Z);
            return id == 46 ? 0 : 0.5f;
        }

        public void InitCreatureTypes(SubsystemCreatureSpawn subsystemCreatureSpawn, List<CreatureType> creatureTypes)
        {
            Random m_random = new Random();
            m_subsystemCreatureSpawn = subsystemCreatureSpawn;
            m_subsystemTerrain = subsystemCreatureSpawn.Project.FindSubsystem<SubsystemTerrain>();
            List<CreatureType> m_creatureTypes = creatureTypes;
            m_creatureTypes.Clear();
            m_creatureTypes.Add(new CreatureType("Duck", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Duck", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Raven", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Raven", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Seagull", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Seagull", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Wildboar", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wildboar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Brown Cattle", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num87 = m_random.Int(3, 5);
                    int num88 = MathUtils.Min(m_random.Int(1, 3), num87);
                    int count2 = num87 - num88;
                    return 0 + SpawnCreatures(creatureType, "Bull_Brown", point, num88).Count + SpawnCreatures(creatureType, "Cow_Brown", point, count2).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Black Cattle", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num83 = m_random.Int(3, 5);
                    int num84 = MathUtils.Min(m_random.Int(1, 3), num83);
                    int count = num83 - num84;
                    return 0 + SpawnCreatures(creatureType, "Bull_Black", point, num84).Count + SpawnCreatures(creatureType, "Cow_Black", point, count).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("White Bull", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bull_White", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Gray", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Coyotes", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Coyote", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Brown Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Brown", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Black Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Black", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Polar Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Polar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Horses", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature28 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num68 = 0;
                    if (m_random.Float(0f, 1f) < 0.35f)
                    {
                        num68 += SpawnCreatures(creatureType, "Horse_Black", point, 1).Count;
                    }
                    if (m_random.Float(0f, 1f) < 0.5f)
                    {
                        num68 += SpawnCreatures(creatureType, "Horse_Bay", point, 1).Count;
                    }
                    if (m_random.Float(0f, 1f) < 0.5f)
                    {
                        num68 += SpawnCreatures(creatureType, "Horse_Chestnut", point, 1).Count;
                    }
                    if (temperature28 > 8 && m_random.Float(0f, 1f) < 0.3f)
                    {
                        num68 += SpawnCreatures(creatureType, "Horse_Palomino", point, 1).Count;
                    }
                    if (temperature28 < 8 && m_random.Float(0f, 1f) < 0.3f)
                    {
                        num68 += SpawnCreatures(creatureType, "Horse_White", point, 1).Count;
                    }
                    return num68;
                }
            });
            m_creatureTypes.Add(new CreatureType("Camels", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Camel", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Donkeys", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Donkey", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Giraffes", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Giraffe", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Rhinos", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Rhino", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Tigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("White Tigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger_White", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Lions", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lion", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Jaguars", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Jaguar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Leopards", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Leopard", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Zebras", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Zebra", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Gnus", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Gnu", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Reindeers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Reindeer", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Mooses", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Moose", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new CreatureType("Bisons", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bison", point, m_random.Int(1, 4)).Count
            });
            m_creatureTypes.Add(new CreatureType("Ostriches", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Ostrich", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Cassowaries", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Cassowary", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Hyenas", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hyena", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Bears", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName11 = (m_random.Int(0, 1) == 0) ? "Bear_Black" : "Bear_Brown";
                    return SpawnCreatures(creatureType, templateName11, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Cave Tigers", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Lions", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                return LightCondition(point); 
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lion", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Jaguars", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Jaguar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Leopards", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Leopard", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Hyenas", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hyena", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Bull Sharks", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) =>
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName10 = "Shark_Bull";
                    return SpawnCreatures(creatureType, templateName10, point, 1).Count;
                }
            });;
            m_creatureTypes.Add(new CreatureType("Tiger Sharks", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) =>
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName9 = "Shark_Tiger";
                    return SpawnCreatures(creatureType, templateName9, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Great White Sharks", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) =>
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName8 = "Shark_GreatWhite";
                    return SpawnCreatures(creatureType, templateName8, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Barracudas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) =>
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName7 = "Barracuda";
                    return SpawnCreatures(creatureType, templateName7, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Bass_Sea", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) =>
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName6 = "Bass_Sea";
                    return SpawnCreatures(creatureType, templateName6, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Bass_Freshwater", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName5 = "Bass_Freshwater";
                    return SpawnCreatures(creatureType, templateName5, point, m_random.Int(1, 2)).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Rays", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num27 = 0;
                    int num28 = 0;
                    for (int i = point.X - 2; i <= point.X + 2; i++)
                    {
                        for (int j = point.Z - 2; j <= point.Z + 2; j++)
                        {
                            if (m_subsystemTerrain.Terrain.GetCellContents(point.X, point.Y, point.Z) == 18)
                            {
                                for (int num29 = point.Y - 1; num29 > 0; num29--)
                                {
                                    switch (m_subsystemTerrain.Terrain.GetCellContents(point.X, num29, point.Z))
                                    {
                                        case 2:
                                            num27++;
                                            break;
                                        case 7:
                                            num28++;
                                            break;
                                        default:
                                            continue;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    string templateName4 = (num27 >= num28) ? "Ray_Brown" : "Ray_Yellow";
                    return SpawnCreatures(creatureType, templateName4, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Piranhas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName3 = "Piranha";
                    return SpawnCreatures(creatureType, templateName3, point, m_random.Int(2, 4)).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Orcas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName2 = "Orca";
                    return SpawnCreatures(creatureType, templateName2, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Belugas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName = "Beluga";
                    return SpawnCreatures(creatureType, templateName, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Gray", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Coyotes", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Coyote", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Brown Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Brown", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Black Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Black", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Polar Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Black", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Tigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Lions", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lion", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Jaguars", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Jaguar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Leopards", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Leopard", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Hyenas", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hyena", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Pigeon", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Pigeon", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Sparrow", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    return LightCondition(point);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int count3 = m_random.Int(1, 2);
                    return SpawnCreatures(creatureType, "Sparrow", point, count3).Count;
                }
            });
        }

        public override void Load()
        {
        }

        public override void Save()
        {
        }

        public void OnEntityAdded(SubsystemCreatureSpawn subsystemCreatureSpawn, Entity entity)
        {
        }

        public void OnEntityRemoved(SubsystemCreatureSpawn subsystemCreatureSpawn, Entity entity)
        {
        }

        public void OnPlayerSpawned(PlayerData playerData, Entity playerEntity, Vector3 position)
        {
        }
    }
}